package com.jack.leetcode.array;

import java.util.Arrays;
import java.util.Scanner;

/***
 * @author zhangjie
 * @date 2020/3/22 22:20
 */
public class 两数之和 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNext()){
            int n = s.nextInt();
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = s.nextInt();
            }
            int target = s.nextInt();
            twoSum(a,target);
        }
    }

    public static int[] twoSum(int[] nums, int target) {
        int []result = new int[2];
        for(int i=0;i<nums.length;i++){
            int next = -1;
            for(int j = i+1;j<nums.length;j++){
                if(nums[j]==target - nums[i]){
                    next = j;
                }
            }
            if(next >= 0 ){
                result[0] = i;
                result[1] = next;
                break;
            }
        }
        System.out.println(result[0]);
        System.out.println(result[1]);
        return result;
    }
}
